//
//  LMJ_MyScrollView.swift
//  GFQM
//
//  Created by iSolar on 2017/5/4.
//  Copyright © 2017年 iSolar. All rights reserved.
//

import UIKit

class LMJ_MyScrollView: UIScrollView,UIScrollViewDelegate {
    func creatMyScrollView(imageName:[String],height:CGFloat) {
        //动态布局
        for i in 0...(imageName.count - 1) {
            let imageView = UIImageView(frame: CGRect(x: CGFloat(i) * width, y: 0, width: width, height: height))
            addSubview(imageView)
            
            //设置轮播图图片
            imageView.image = UIImage(named: imageName[i])
        }
        //设置轮播图容量
        self.contentSize = CGSize(width:CGFloat(imageName.count) * width,height:0)
        //设置吸附属性
        self.bounces = false
        self.showsHorizontalScrollIndicator = false
        //设置书页效果
        self.isPagingEnabled = true
        
        //单独创建第n+1张轮播图，和第一张图片是同一张图
        let imageView = UIImageView(frame:CGRect(x: CGFloat(imageName.count) * width, y: 0, width: width, height: height))
        imageView.image = UIImage(named:imageName[0])
        self.addSubview(imageView)
        
    }

}
